package com.jiaquyun.jcps.mode.manager

import com.jiaquyun.jcps.app.BaseApplication
import com.jiaquyun.jcps.entity.*
import com.jiaquyun.jcps.mode.api.Mine2Api
import com.lemlin.network.HttpServiceData
import com.lemlin.network.HttpServiceManager
import com.lemlin.network.HttpServiceSubscribe
import com.lemlin.network.SubscribeListener
import io.reactivex.disposables.Disposable

class MineManager : HttpServiceManager<Mine2Api>(Mine2Api::class.java) {


    /**
     * 个人页数据
     */
    fun personalData(
        listener: SubscribeListener<PersonalResponse>
    ): Disposable =
        subscribe(
            apiService.personalData(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )

    /**
     * 今日数据
     */
    fun todayData(
        listener: SubscribeListener<TodayResponse>
    ): Disposable =
        subscribe(
            apiService.todayData(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )

    /**
     * 个人信息
     */
    fun userInfo(
        listener: SubscribeListener<UserInfo2Response>
    ): Disposable =
        subscribe(
            apiService.userInfo(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )

    /**
     *结算
     * */
    fun cashAdd(
        listener: SubscribeListener<HttpServiceData>
    ): Disposable =
        subscribe(
            apiService.cashAdd(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )

    /**
     *结算
     * */
    fun cashLog(
        page: String, limit: String,
        listener: SubscribeListener<SettleResponse>
    ): Disposable =
        subscribe(
            apiService.cashLog(BaseApplication.userToken(), page, limit),
            HttpServiceSubscribe(listener)
        )

    /**
     * 考勤打卡数据
     * */
    fun punchTheClock(
        listener: SubscribeListener<SignClockResponse>
    ): Disposable =
        subscribe(
            apiService.punchTheClock(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )

    fun goOffWork(
        listener: SubscribeListener<HttpServiceData>
    ): Disposable =
        subscribe(
            apiService.goOffWork(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )

    fun goToWork(
        listener: SubscribeListener<HttpServiceData>
    ): Disposable =
        subscribe(
            apiService.goToWork(BaseApplication.userToken()),
            HttpServiceSubscribe(listener)
        )
}